from django.db import models
import os

# Create your models here.
class Tag(models.Model):
    TID = models.CharField(max_length = 10,primary_key=True)
    TagName = models.CharField(max_length=16)
    TagImage = models.CharField(max_length=100)
    TagCategory = models.CharField(max_length=100)
    TagMajor = models.BooleanField()

class Product(models.Model):
    PID = models.CharField(max_length=16, primary_key=True)
    ProdName = models.CharField(max_length=16)
    ProdIntro = models.CharField(max_length=2000)
    ProdTime = models.DateTimeField(auto_now_add=True) # 字段创建时自动添加
    ProdSellerID = models.ForeignKey("User.User", on_delete=models.CASCADE) # 卖家ID，外键
    ProdPrice = models.FloatField()
    # 图片类型
    ProdImage1 = models.CharField(max_length=100) 
    ProdImage2 = models.CharField(max_length=100) 
    ProdImage3 = models.CharField(max_length=100) 
    # 标签，最多设置为5个，字符最大长度限制为16
    ProdTag1 = models.ForeignKey("Product.Tag", on_delete=models.CASCADE, related_name='ProdTag1')
    ProdTag2 = models.ForeignKey("Product.Tag", on_delete=models.CASCADE, related_name='ProdTag2')
    ProdTag3 = models.ForeignKey("Product.Tag", on_delete=models.CASCADE, related_name='ProdTag3')
    ProdTag4 = models.ForeignKey("Product.Tag", on_delete=models.CASCADE, related_name='ProdTag4')
    ProdTag5 = models.ForeignKey("Product.Tag", on_delete=models.CASCADE, related_name='ProdTag5')
    ProdTag = models.CharField(max_length=60)


